package com.example.speeddating.controller;


import com.example.speeddating.annotaion.LoginUser;
import com.example.speeddating.annotaion.TokenCheck;
import com.example.speeddating.common.BaseResponse;
import com.example.speeddating.common.RespGenerator;
import com.example.speeddating.entity.TokenEntity;
import com.example.speeddating.service.MessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class ConversationController {

    @Autowired
    private MessageService messageService;

    /**
     * 删除会话
     * @param tokenEntity
     * @param id
     * @return
     */
    @TokenCheck(roles = "user")
    @RequestMapping("/user/conversation/delete/{id}")
    public BaseResponse deleteConversation(@LoginUser TokenEntity tokenEntity, @PathVariable Long id){
        messageService.deleteConversation(tokenEntity.getId(),id);
        return RespGenerator.returnOK("删除成功");
    }
}
